Ext.apply(Ext.form.VTypes, {//下拉树模糊查询校验
	treeComboboxQueryValid : function(val, me) {// val:文本框值，tree:文本框组件
		var tree = me.picker;
		var treeStroe = me.getStore();
    	var roonodes = treeStroe.getRootNode();
		if(me.config.checkModel=="multi"){
			if(tree && tree.getChecked().length>0){
				return true;
			}else{
				var vals = val.split(";");
				for(var value = 0; value < vals.lenth; value++){
					if(!findValueByStore(roonodes,vals[value])){
						me.setRawValue('');
						me.value = '';
		        	}
				}
				return true;
			}
    	}else{
        	if(findValueByStore(roonodes,val)){
        		return true;
        	}
    	}
		me.setRawValue('');
		me.value = '';
    }
});
/**
 * 判断是否选中下拉框中的值
 * @param node
 * @param text
 * @returns {Boolean}
 */
function findValueByStore(node,text){
    var childnodes = node.childNodes;
    for(var i=0;i<childnodes.length;i++){  //从节点中取出子节点依次遍历
        var rootnode = childnodes[i];
        if ((rootnode.data.name && rootnode.data.name==text) || rootnode.data.text==text) {
            return true;
        }
        if(rootnode.childNodes.length>0){  //判断子节点下是否存在子节点
        	if(findValueByStore(rootnode,text)==true){
        		return true;
        	} //如果存在子节点  递归
        }
    }
}
/**
 * 改编自ext.ux.treepicker
 * A Picker field that contains a tree panel on its popup, enabling selection of tree nodes.
 */
Ext.define('Ext.ux.TreeCombobox', {
    extend: 'Ext.form.field.Picker',
    xtype: 'treecombobox',

    uses: [
        'Ext.tree.Panel'
    ],

    triggerCls: [Ext.baseCSSPrefix + 'form-arrow-trigger'],
    config: {
    	vtype : "treeComboboxQueryValid",// 自定义的验证类型
        vtypeText : "必须选择下拉树中数据！",
        selectOrKeypress: 'select',
        /**
         * @cfg {Ext.data.TreeStore} store
         * A tree store that the tree picker will be bound to
         */
        store: null,

        /**
         * @cfg {String} displayField
         * The field inside the model that will be used as the node's text.
         * Defaults to the default value of {@link Ext.tree.Panel}'s `displayField` configuration.
         */
        displayField: null,
        valueField: null,

        /**
         * @cfg {Array} columns
         * An optional array of columns for multi-column trees
         */
        columns: null,

        /**
         * @cfg {Boolean} selectOnTab
         * Whether the Tab key should select the currently highlighted item. Defaults to `true`.
         */
        selectOnTab: true,

        /**
         * @cfg {Number} maxPickerHeight
         * The maximum height of the tree dropdown. Defaults to 300.
         */
        maxPickerHeight: 300,

        /**
         * @cfg {Number} minPickerHeight
         * The minimum height of the tree dropdown. Defaults to 100.
         */
        minPickerHeight: 240,
        /**
         * @cfg {Number} minPicekerWidth
         * The minimum width of the tree dropdown. Defaults to null.
         */
        minPicekerWidth: 300,
        /**
         * @cfg {Number} minPicekerWidth
         * The minimum width of the tree dropdown. Defaults to null.
         */
        maxPicekerWidth: 1920,
        /**
         * @cfg {Boolean} rootVisible
         * 是否显示根节点.Defaults to 'true'.
         */
        rootVisible: true,
        checkModel: 'single',//值：single，multi
        rootUse: false,

        /**
         * @cfg {String} selectModel
         * 节点选中方式，值为:'leaf'、'all'.Defaults to 'all'.
         */
        selectModel: 'all',
        /**
         * @default 查询显示值	displayField
         * @all 查询显示值以及存储值 valueField,displayField
         */
        findModel: "display",
        cascadeChecked: false
    },
    enableKeyEvents: true,
    editable: true,

    /**
     * @event select
     * Fires when a tree node is selected
     * @param {Ext.ux.TreePicker} picker        This tree picker
     * @param {Ext.data.Model} record           The selected record
     */
    listeners: {
    	render: function(self, eOpts) {
    		if(!!self.config.allowBlank) {
    			var clearDom = document.createElement("div");
    			clearDom.setAttribute("style", "background: transparent url(/report/image/common/clear-trigger.png) no-repeat; width: 22px;" +
    					"background-position:0px 0px;display:table-cell;cursor:pointer");
    			self.triggerWrap.dom.appendChild(clearDom);
    			clearDom.onclick = (function() {
    				self.setRawValue("");
    				self.setValue("");
                    self.fireEvent('change',self, "");
    			});
    		}
            if(self.config.editable) {
                $(self.el.dom).find("input")[0].onclick = function() {
                    var picker = self.picker;
                    if (!picker) {
                        picker = self.createPicker();
                    }
                    self.expand();
                }
                $($(self.el.dom).find("input")[0]).on('input', function(){
                    if(Ext.isEmpty($(self.el.dom).find("input")[0].value)) {
                        self.setValue("");
                    }
                });
            }
    	}
    },

    initComponent: function () {
        var me = this;
        me.callParent(arguments);
        me.mon(me.store, {
            scope: me,
            load: me.onLoad,
            update: me.onUpdate
        });
        me.mon(me, {
            keydown: me.onKeydown
            //keyup :me.onKeyup
        });
    },

    /**
     * Creates and returns the tree panel to be used as this field's picker.
     */
    createPicker: function () {
        var me = this;


        var picker = Ext.create('Ext.tree.Panel', {
                shrinkWrapDock: 2,
                pickerField: me,
                store: me.store,
                floating: true,
                displayField: me.displayField,
                focusOnToFront: false,
                height: 300,
                columns: me.columns,
                minHeight: me.minPickerHeight,
                maxHeight: me.maxPickerHeight,
                minWidth: me.minPicekerWidth,
                maxWidth: me.maxPicekerWidth,
                manageHeight: false,
                rootVisible: me.rootVisible,
                shadow: false,
                resizable: true,
                listeners: {
                    scope: me,
                    beforeselect: me.beforeselect,
                    itemclick: me.onItemClick,
                    itemmouseenter: me.itemmouseenter
                },
                viewConfig: {
                    listeners: {
                        scope: me,
                        render: me.onViewRender
                    }
                }
            }),
            view = picker.getView();
        if (Ext.isIE9 && Ext.isStrict) {
            // In IE9 strict mode, the tree view grows by the height of the horizontal scroll bar when the items are highlighted or unhighlighted.
            // Also when items are collapsed or expanded the height of the view is off. Forcing a repaint fixes the problem.
            view.on({
                scope: me,
                highlightitem: me.repaintPickerView,
                unhighlightitem: me.repaintPickerView,
                afteritemexpand: me.repaintPickerView,
                afteritemcollapse: me.repaintPickerView
            });
        }
        return picker;
    },
    beforeselect: function ( self, record, index, eOpts ){
        this.fireEvent('beforeselect', self, record, index, eOpts);
    },
    itemmouseenter: function(self, record, item, index, e, eOpts){
    	this.fireEvent('itemmouseenter', self, record, item, index, e, eOpts);
    },

    onViewRender: function (view) {
    	var me = this;
        view.getEl().on('keypress', this.onPickerKeypress, this);
        $(view.getEl().dom).addClass("x-treecombo-ui-trigger");
        var checkModel = me.checkModel;
        if (checkModel == 'multi') {
	        for(var i = 0, length = me.store.data.items.length; i < length; i++){
	        	me.initTreeChecked(me.store.data.items[i], false);
	        }
	        // 解决下拉树展开未选中问题
	        if(!!me.value){
	        	var valuesArr = me.value.split(",");
	        	for(var i = 0; i < valuesArr.length; i++){
	        		var node = me.store.getNodeById(valuesArr[i]);
	        		if(!!node){
	    				node.set("checked", true);
	        			me.picker.expandPath(node.getPath('id'));
	        		}
	        	}
	        }
        }
        if(me.bodyEl.getWidth() < 300){
			me.picker.setWidth(300);
		}
    },

    initTreeChecked: function (node, checked) {
        var me = this;
        if (node.hasChildNodes()) {
            node.eachChild(function (child) {
                child.set('checked', checked);
                me.initTreeChecked(child, checked); //递归调用
            });
        }
        if (me.selectModel == 'all') {
            node.set('checked', checked||false);
        }
    },

    /**
     * repaints the tree view
     */
    repaintPickerView: function () {
        var style = this.picker.getView().getEl().dom.style;

        // can't use Element.repaint because it contains a setTimeout, which results in a flicker effect
        style.display = style.display;
    },

    /**
     * Handles a click even on a tree node
     * @private
     * @param {Ext.tree.View} view
     * @param {Ext.data.Model} record
     * @param {HTMLElement} node
     * @param {Number} rowIndex
     * @param {Ext.event.Event} e
     */
    onItemClick: function (view, record, node, rowIndex, e) {
        var me = this;
        if(!me.fireEvent('beforeselect', me, record)){
            return false;
        }
        if (me.selectModel == 'all') {
            this.selectItem(record);
        } else if (me.selectModel == 'leaf') {
            if (record.isLeaf() || record.isRoot()) {
                this.selectItem(record);
            } else {
                if (record.isExpanded()) {
                    view.collapse(record);
                }
                else {
                    view.expand(record);
                }
            }
        }
    },

    /**
     * Handles a keypress event on the picker element
     * @private
     * @param {Ext.event.Event} e
     * @param {HTMLElement} el
     */
//    onPickerKeypress: function(e, el) {
//        var key = e.getKey();
//
//        if(key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
//            this.selectItem(this.picker.getSelectionModel().getSelection()[0]);
//        }
//    },

    /**
     * Changes the selection to a given record and closes the picker
     * @private
     * @param {Ext.data.Model} record
     */
    selectItem: function (record) {
        var me = this;
        me.selectOrKeypress = 'select';
        var checkModel = me.checkModel;
        var rootUse = me.rootUse;
        if (record.isRoot()) {
            var checked = record.get('checked');
            if (rootUse || record.id == 'root') {
                if (checked) {
                    record.set('checked', false);
                    if(checkModel == 'multi') {
                        record.cascadeBy(function (child) {
                            child.set('checked', false);
                        });
                    }
                    me.setRawValue("");
                    me.value = "";
                } else {
                    record.set('checked', true);
                    if(checkModel == 'multi') {
                        record.cascadeBy(function (child) {
                            child.set('checked', true);
                        });
                    }
                    me.setRawValue("全部");
                    me.value = "";
                }
                if(!!record.childNodes && record.childNodes.length == 1 && !!record.firstChild && !! !!record.firstChild.expand) {
                    record.firstChild.expand();
                }

                /*var records = me.picker.getView().getChecked();
                Ext.Array.each(records, function (rec) {
                    if (!rec.isRoot()) {
                        rec.set('checked', false);
                    }
                });*/
                me.fireEvent('select', me, record);
                me.fireEvent('change',me,me.value);
            } else {
                me.setValue("");
                // 当选择ROOT节点时，添加select和change事件
                me.fireEvent('select', me, record);
                me.fireEvent('change',me,me.value);
            }
        }else {
            var checked = record.get('checked');
            if (checkModel == 'single') {
                me.setValue(record.getId());
                me.fireEvent('select', me, record);
                me.collapse();
            } else if (checkModel == 'multi') {
                if (checked) {
                    record.set('checked', false);
                    me.setTreeChecked(record, false);
                    if(me.cascadeChecked) {
                        record.bubble(function(parentNode) {
                            if (!parentNode.hasChildNodes() || !parentNode.childNodes.some(function(childNode) {return childNode.get('checked');})) {
                                parentNode.set('checked', false);
                            }
                        });
                    }
                } else {
                    record.set('checked', true);
                    me.setTreeChecked(record, true);
                    if(me.cascadeChecked) {
                        record.bubble(function(parentNode) {
                            if(parentNode.id != "root") {
                                parentNode.set('checked', true);
                            }
                        });
                    }
                }

                var records = me.picker.getView().getChecked(),
                    names = [],
                    values = [];
                var flag = false;
                //valueField  displayField
                var displayField = me.displayField;
                var valueField = me.valueField;
                Ext.Array.each(records, function (rec) {
                    if (rec.isRoot()) {
                        rec.set('checked', false);//级联优化，如果全部下点击其它节点取消全部勾选
                        return;
                        //flag = true;
//            		return;
                    }
                    if (displayField != null) {
                        names.push(rec.get(displayField));
                    } else {
                        names.push(rec.get('text'));
                    }

                    if (valueField != null) {
                        values.push(rec.get(valueField));
                    } else {
                        values.push(rec.get('code'));
                    }

                });
                if (flag) {
//            	Ext.Array.each(records, function (rec) {
//                	if(!rec.isRoot()){
//                		rec.set('checked', false);
//                	}
//               });
                    me.setRawValue("全部");
                    me.value = "";
                } else {
                    me.setRawValue(names.join(';'));
                    me.value = values.join(',');
                    me.fireEvent('select', me, record);
                }
                me.fireEvent('change',me,me.value);
//            me.collapse();
            }
			me.validateValue(me.rawValue);
        }
    },

    setTreeChecked: function (node, checked) {
        var me = this;
        if (node.hasChildNodes()) {
            node.expand();
            node.eachChild(function (child) {
                child.set('checked', checked);
                me.setTreeChecked(child, checked); //递归调用
            });
        }
    },

    /**
     * Runs when the picker is expanded.  Selects the appropriate tree node based on the value of the input element,
     * and focuses the picker so that keyboard navigation will work.
     * @private
     */
    onExpand: function () {
        var me = this,
            picker = me.picker,
            store = picker.store,
            valueId = me.valueId,
            node;
        if (valueId) {
            node = store.getNodeById(valueId);
        }
        if (!node) {
            node = store.getRoot();
        }
        //当展开时，获取picker项left位置，然后设置
        /*var pickerLeft = me.getX();
         if (me.getFieldLabel() != null && me.getFieldLabel() != '') {
         pickerLeft = pickerLeft + me.labelWidth + 5;
         }
         if (pickerLeft != picker.getX()) {
         picker.setX(pickerLeft);
         }*/
        picker.selectPath(node.getPath());
    },

    /**
     * Sets the specified value into the field
     * @param {Mixed} value
     * @return {Ext.ux.TreePicker} this
     */
    setValue: function (valueId) {
        var me = this,
            record;
        me.valueId = valueId;
        if (me.store.loading) {
            // Called while the Store is loading. Ensure it is processed by the onLoad method.
            return me;
        }
        var checkModel = me.checkModel;
        if (checkModel == 'multi') {
            var multiRecord;
            if (!valueId) {
                me.setRawValue('');
                me.value = '';
    	        for(var i = 0, length = me.store.data.items.length; i < length; i++){
    	        	me.store.data.items[i].set("checked", false);
    	        	me.initTreeChecked(me.store.data.items[i], false)
    	        }
                return me;
            }
            var strArray = valueId.split(',');
            var names = [], values = [];
            Ext.Array.forEach(strArray, function (str) { //单纯的遍历数组
                multiRecord = str ? me.store.getNodeById(str) : me.store.getRoot();
                if(multiRecord){
                    multiRecord.set('checked', true);
                    names.push(multiRecord ? multiRecord.get(me.displayField) : '');
                    values.push(multiRecord ? multiRecord.get(me.valueField) : '');
                }
            });
            me.setRawValue(names.join(';'));
            me.value = values.join(',');
            this.fireEvent('change',me,me.value);
            return me;
        }

        // try to find a record in the store that matches the value
        if(!!valueId) {
        	record = me.store.getNodeById(valueId);
        }
        // 判断如果配置的valueField不是id，则需要根据valueId找到该条数据的id，然后根据id定位
        if(!record && this.valueField != "id"){
        	var countMap = me.store.byIdMap;
        	for(var mapKey in countMap){
        		if(countMap[mapKey] && countMap[mapKey].data && countMap[mapKey].data[this.valueField] == valueId){
        			record = countMap[mapKey];
        			break;
        		}
        	}
        }
        if(!record){
        	record = me.store.getRoot();
    		me.valueId = record.getId();
    		me.setRawValue("");
    		me.value = "";
    		return me;
        }
        // set the raw value to the record's display field if a record was found
        me.setRawValue(record ? record.get(me.displayField) : '');
        me.value = record ? record.get(me.valueField) : '';
        this.fireEvent('change',me,me.value);
        return me;
    },

    getSubmitValue: function () {
        return this.value;
    },

    /**
     * Returns the current data value of the field (the idProperty of the record)
     * @return {Number}
     */
    getValue: function () {
        return this.value;
    },

    /**
     * Handles the store's load event.
     * @private
     */
    onLoad: function () {
        var valueId = this.valueId;
        if (valueId) {
            this.setValue(valueId);
        }
        this.fireEvent('change',this,this.value);
    },

    onUpdate: function (store, rec, type, modifiedFieldNames) {
        var display = this.displayField;
        if (type === 'edit' && modifiedFieldNames && Ext.Array.contains(modifiedFieldNames, display) && this.valueId === rec.getId()) {
            this.setRawValue(rec.get(display));
        }
    },
    /*onBlur: function () {
     var me = this;
     if (me.selectOrKeypress == 'keypress') {
     var picker = me.createPicker();
     var text = me.getRawValue();
     if (text != null && text != 'undefined' && text.length > 0) {

     var treeStore = picker.store;
     for (var i = 0; i < treeStore.getCount(); i++) {
     var record = treeStore.getAt(i);
     var value = record.get(me.displayField);
     if (typeof value != 'undefined' && value != null && value.indexOf(text) >= 0) {
     me.setValue(record.get(me.valueField));
     return;
     }
     }
     me.setValue('');
     }
     else {
     me.setValue('');
     }
     }
     },*/
    onKeydown: function (self, e) {
        var me = this;
        var key = e.getKey();
        if (key === e.ENTER || (key === e.TAB && this.selectOnTab)) {
            var picker = me.picker;
            if (!picker) {
                picker = me.createPicker();
            }
            var text = me.getRawValue();
            if (text != null && text != 'undefined' && text.length > 0) {
            	me.expand();
                var treeStore = picker.store;
                me.treeSearch();
            }else {
            	/*if (me.checkModel == 'single' && picker.getSelection() && picker.getSelection().length > 0) {
                }*/
            	picker.getSelectionModel().clearSelections();
            	picker.getView().refresh();
            	picker.getView().scrollTo(0, 0, true);
            	//me.setValue('');
            }
        } else {
            me.selectOrKeypress = 'keypress';
        }
    },
    onKeyup:function (self, e) {
        var me = this;
        var picker = me.picker;
        if (!picker) {
            picker = me.createPicker();
        }
        var text = me.getRawValue();
        if (text != null && text != 'undefined' && text.length > 0) {
        	me.expand();
            var treeStore = picker.store;
            me.treeSearch();
        }else {
        	if (me.checkModel == 'single' && picker.getSelection() && picker.getSelection().length > 0) {
        		picker.getSelectionModel().clearSelections();
        		picker.getView().refresh();
            }
        	me.search_result = [];
        	picker.getView().scrollTo(0, 0, true);
        	me.setValue('');
        }
    },
    /**
     * 树检索
     * @param self 搜索按钮/检索框
     */
    treeSearch: function () {
        var me = this;
        var tree = me.picker;
        var roonodes = tree.getRootNode();//获取主节点
        var treeStroe = me.picker.getStore();
        var text = me.getRawValue();
        /*var nodes = tree.getChecked();
         if (nodes && nodes.length > 0) {
         for (var i = 0; i < nodes.length; i++) {
         //设置UI状态为未选中状态
         //nodes[i].getUI().toggleCheck(false);
         //设置节点属性为未选中状态
         nodes[i].attributes.checked = false;
         }
         }*/
        //如果搜索框内容与上次搜索内容不一致，更新
        if (!me.search_value || me.search_value.toLowerCase() != text.toLowerCase()) {
        	if (me.checkModel == 'single' && tree.getSelection() && tree.getSelection().length > 0) {
                tree.getSelectionModel().clearSelections();
                tree.getView().refresh();
            }
        	if (typeof(me.search_result)=="undefined") {
        		me.search_result = new Array();
        		me.search_resultCount = 0;
        	}
        	me.search_result=[];
        	me.search_resultCount = 0;
            me.search_start = 0;
            me.search_value = text;
        }else{
        	if(typeof(tree.getSelectionModel().getSelection()[0])!="undefined"){
        		if(!arrayContains(me.search_result,tree.getSelectionModel().getSelection()[0].data.name)){
        			me.search_result[me.search_resultCount] = tree.getSelectionModel().getSelection()[0].data.name;
        			me.search_resultCount = me.search_resultCount+1;
        		}
            }
        }
        me.isNanFindCount = 0;
        me.findCount = 0;
        expandLeafByFinddata(roonodes,tree,text,me.search_result,"treeCombobox",isNaN(text),(me.config.findModel == 'all'),me);  //开始递归
        //循环store，检索搜索内容是否存在
        var start_index = me.search_start;
        var find = false;
        while (true) {
            me.search_start++;
            if (me.search_start >= treeStroe.getCount()) {
                me.search_start = 0;
            }
            var record = treeStroe.getAt(me.search_start);
            if (!record) {
                break;
            }
            /*if (!record.get('leaf')) {
                tree.expandPath(record.getPath('id'));
            }*/
            var value_display = record.get(me.displayField);
            var value_value = record.get(me.valueField);
            if (isNaN(text) && ((me.config.findModel == 'all' && (value_value && value_value.toLowerCase().indexOf(text.toLowerCase()) >= 0)) || (value_display && value_display.toLowerCase().indexOf(text.toLowerCase()) >= 0))) {
            	if(me.checkModel == 'single' && me.isNanFindCount<2 && record.childNodes.length==0){
            		me.setValue(record.getId());
                    me.fireEvent('select', me, record);
                    me.fireEvent('change', me, record.id);
                    me.collapse();
            	}
            	tree.expandPath(record.getPath('id'));
            	var scorll_height = me.search_start * (tree.getView().getNodes()[0].clientHeight) > 100 ? me.search_start * (tree.getView().getNodes()[0].clientHeight) - 100 : 0;
                tree.getSelectionModel().select(record);
                tree.getView().scrollTo(0, scorll_height, true);
                break;
            }else if(!isNaN(text) && ((me.config.findModel == 'all' && (value_value && (value_value.substring(0,text.length)==text)) || (value_display && value_display.substring(0,text.length)==text)))){
            	if(me.onlyOneCode && me.checkModel == 'single' || (me.search_result.length==1 && me.search_result[0]==value_display)){
            		me.setValue(record.getId());
                    me.fireEvent('select', me, record);
                    me.fireEvent('change', me, record.id);
                    me.collapse();
            	}
            	tree.expandPath(record.getPath('id'));
            	var scorll_height = me.search_start * (tree.getView().getNodes()[0].clientHeight) > 100 ? me.search_start * (tree.getView().getNodes()[0].clientHeight) - 100 : 0;
                tree.getSelectionModel().select(record);
                tree.getView().scrollTo(0, scorll_height, true);
                break;
            }
            if (start_index == me.search_start) {
                break;
            }
        }
    }
});
/**
 * 判断数组中是否包含某元素
 * @param selectValue
 * @param obj
 * @returns {Boolean}
 */
function arrayContains(selectValue,obj){
	var i = selectValue.length;
	  while (i--) {
	    if (selectValue[i] == obj) {
	      return true;
	    }
	  }
	  return false;
}
/**
 * 展开查询到数据的节点
 * @param node
 * @param tree
 * @param text
 * @param selectValue
 * @returns {Boolean}
 */
function expandLeafByFinddata(node,tree,text,selectValue,treeType,isNan,isQueryId,me){
    var childnodes = node.childNodes;
    for(var i=0;i<childnodes.length;i++){  //从节点中取出子节点依次遍历
        var rootnode = childnodes[i];
    	var leafname = rootnode.data.text;
    	if(isQueryId){
    		leafname = leafname + " "+rootnode.data.id;
    	}
        if (isNan && (leafname && leafname.toLowerCase().indexOf(text.toLowerCase()) >= 0)) {
        	if(treeType == "treeCombobox"){
        		me.isNanFindCount++;
        		if(!arrayContains(selectValue,leafname)){
            		me.findCount++;
            		if(me.findCount<2){
            			tree.expandPath(rootnode.getPath('id'));
            		}
            	}
        	}else{
        		if(!arrayContains(selectValue,rootnode.data.text)){
        			tree.expandPath(rootnode.getPath('id'));
            		if(treeType == "treeCombobox"){
            			if(me.checkModel == 'single' && text == rootnode.data.code && rootnode.childNodes.length==0){
            				me.onlyOneCode = true;
            				return false;
            			}else{
            				me.onlyOneCode = false;
            			}
            		}
            		return false;
            	}
        	}
        }else if(!isNan && leafname && leafname.substring(0,text.length)==text){
        	if(!arrayContains(selectValue,leafname)){
        		tree.expandPath(rootnode.getPath('id'));
        		if(treeType == "treeCombobox"){
        			if(me.checkModel == 'single' && text == rootnode.data.code && rootnode.childNodes.length==0){
        				me.onlyOneCode = true;
        				return false;
        			}else{
        				me.onlyOneCode = false;
        			}
        		}
        		return false;
        	}
        }
        if(rootnode.childNodes.length>0){  //判断子节点下是否存在子节点
        	//如果存在子节点  递归
        	if(expandLeafByFinddata(rootnode,tree,text,selectValue,treeType,isNan,isQueryId,me)==false){
        		return false;
        	}
        }
    }
}
